<template>
  <div :class="styles['all-send']">
    <div :class="styles['header-search']">
      <h2 class="ato-title">待发货订单列表:</h2>
      <UidSearchBar tips="输入销售订单UID或发货物流单号，可搜索已发货订单信息：">
        <el-form inline :model="searchForm" style="margin-top: 6px">
          <el-form-item label="销售订单UID:">
            <el-input v-model="searchForm.orderNo" placeholder="销售订单UID" clearable style="width: 200px"/>
          </el-form-item>
          <el-form-item label="物流单号:">
            <el-input v-model="searchForm.trackingNo" placeholder="物流单号" clearable style="width: 200px"/>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="handleSearch">搜索</el-button>
            <el-button @click="handleSearch(true)">重置</el-button>
          </el-form-item>
        </el-form>
      </UidSearchBar>
    </div>
    <OutStoreList class="ato-mt-12" :cardStatus="4"  @handleDetail="goDetail" ref="outStoreListRef"/>
    <el-drawer v-model="detail.open" :with-header="false" size="100%" destroy-on-close :show-close="false" :close-on-press-escape="false">
      <SendOrderDetail :cardId="detail.cardId" @close="detail.open = false"/>
    </el-drawer>
  </div>
</template>

<script setup name="AllSend">
import {reactive, ref} from 'vue'
import { OutStoreList, UidSearchBar } from '@/components'
import SendOrderDetail from './SendOrderDetail'

// 搜索表单
const searchForm = reactive({
  trackingNo: '',
  orderNo: ''
})

// 详情页
const detail = reactive({
  open: false,
  state: {},
  cardId: ''
})

const outStoreListRef = ref(null)

// 搜索按钮
function handleSearch (isReset = false) {
  if (isReset) {
    searchForm.trackingNo = ''
    searchForm.orderNo = ''
  }
  outStoreListRef.value.onLoad({
    trackingNo: searchForm.trackingNo,
    orderNo: searchForm.orderNo
  })
}

// 表格查看详情
function goDetail (id) {
  detail.open = true
  detail.cardId = id
}


</script>

<style lang="less" module="styles" src="./index.less"></style>
